package com.oa.lms.apps.actions.notice;


import java.util.List;

import com.oa.lms.apps.actions.BasicAction;
import com.oa.lms.apps.business.notice.IMessageInfoService;
import com.oa.lms.apps.constants.IDEDStatus;
import com.oa.lms.apps.entity.absence.AbsenceOrderValue;
import com.oa.lms.apps.entity.notice.MessageInfoValue;
import com.oa.lms.apps.entity.user.UsersValue;



@SuppressWarnings("serial")
public class MessageInfoAction extends BasicAction {
	

	private IMessageInfoService messageInfoService;
	private AbsenceOrderValue orderInfo;
	private List<MessageInfoValue> messageInfoList;
	
	private Integer messageId;
	private String title;
	private String contents;
	private Integer status;
	private UsersValue userInfo;
	
	public String toListMessageInfo(){
		userInfo = (UsersValue) session.get("login_userInfo");
		totalpage = messageInfoService.getTotalPageNumber(userInfo.getUserId(), rows);
		messageInfoList = messageInfoService.queryMessageInfo(userInfo.getUserId(), null, rows, currpage);
		return SUCCESS;
	}
	
	public String queryMessageNum() throws Exception{
		String number ="";
		userInfo = (UsersValue) session.get("login_userInfo");
		messageInfoList = messageInfoService.queryMessageInfo(userInfo.getUserId(), IDEDStatus.DISABLE,100, 1);
		if(messageInfoList.size() != 0 && messageInfoList != null){
			number = Integer.toString(messageInfoList.size());
		}else{
			number = "0";
		}
		response.setContentType("text/html; charset=UTF-8");
		response.setHeader("Cache-Control", "no-cache");
		response.getWriter().write(number);
		return null;
	}
	
	public String toDeleteMessageInfo(){
		 messageInfoService.delete(messageId);
		return SUCCESS;
	}
	
	public String toRead(){
		 messageInfoService.toRead(messageId);
		return SUCCESS;
	}



	public IMessageInfoService getMessageInfoService() {
		return messageInfoService;
	}


	public void setMessageInfoService(IMessageInfoService messageInfoService) {
		this.messageInfoService = messageInfoService;
	}


	public List<MessageInfoValue> getMessageInfoList() {
		return messageInfoList;
	}


	public void setMessageInfoList(List<MessageInfoValue> messageInfoList) {
		this.messageInfoList = messageInfoList;
	}





	public Integer getMessageId() {
		return messageId;
	}


	public void setMessageId(Integer messageId) {
		this.messageId = messageId;
	}


	public String getTitle() {
		return title;
	}


	public void setTitle(String title) {
		this.title = title;
	}


	public String getContents() {
		return contents;
	}


	public void setContents(String contents) {
		this.contents = contents;
	}


	public Integer getStatus() {
		return status;
	}


	public void setStatus(Integer status) {
		this.status = status;
	}


	public AbsenceOrderValue getOrderInfo() {
		return orderInfo;
	}


	public void setOrderInfo(AbsenceOrderValue orderInfo) {
		this.orderInfo = orderInfo;
	}




	public UsersValue getUserInfo() {
		return userInfo;
	}




	public void setUserInfo(UsersValue userInfo) {
		this.userInfo = userInfo;
	}

	
	
}
